

//CONSTANTS

//comandos

#define   R_REGISTER      0x00
#define   W_REGISTER      0x20
#define   R_RX_PAYLOAD    0x61
#define   W_TX_PAYLOAD    0xA0
#define   FLUSH_TX        0xE1
#define   FLUSH_RX        0xE2
#define   REUSE_TX_PL     0xE3
#define   ACTIVATE        0x50
#define   R_RX_PL_WID     0x60
#define   W_ACK_PAYLOAD   0xA8
#define   W_TX_PAYLOAD_NOACK  0xB0
#define   NOP             0xFF


//registradores

#define		CONFIG		0x00
//bits
#define         PRIM_RX         0x01
#define         PWR_UP          0x02
#define         CRCO            0x04
#define         EN_CRC          0x08
#define         MASK_MAX_RT     0x10
#define         MASK_TX_DS      0x20
#define         MASK_RX_DR      0x40


#define		EN_AA		0x01
//bits
#define         ENAA_P0         0x01
#define         ENAA_P1         0x02
#define         ENAA_P2         0x04
#define         ENAA_P3         0x08
#define         ENAA_P4         0x10
#define         ENAA_P5         0x20


#define		EN_RXADDR	0x02
//bits
#define         ERX_P0         0x01
#define         ERX_P1         0x02
#define         ERX_P2         0x04
#define         ERX_P3         0x08
#define         ERX_P4         0x10
#define         ERX_P5         0x20


#define		SETUP_AW	0x03
//bits
#define         AW             0x03
#define         AW_3           0x01
#define         AW_4           0x02
#define         AW_5           0x03


#define		SETUP_RETR	0x04
//bits
#define         ARC             0x0F
#define         ARC_0           0x00
#define         ARC_1           0x01
#define         ARC_2           0x02
#define         ARC_3           0x03
#define         ARC_4           0x04
#define         ARC_5           0x05
#define         ARC_6           0x06
#define         ARC_7           0x07
#define         ARC_8           0x08
#define         ARC_9           0x09
#define         ARC_10          0x0A
#define         ARC_11          0x0B
#define         ARC_12          0x0C
#define         ARC_13          0x0D
#define         ARC_14          0x0E
#define         ARC_15          0x0F
#define         ARD             0xF0
#define         ARD_250         0x00
#define         ARD_500         0x10
#define         ARD_750         0x20
#define         ARD_1000        0x30
#define         ARD_1250        0x40
#define         ARD_1500        0x50
#define         ARD_1750        0x60
#define         ARD_2000        0x70
#define         ARD_2250        0x80
#define         ARD_2500        0x90
#define         ARD_2750        0xA0
#define         ARD_3000        0xB0
#define         ARD_3250        0xC0
#define         ARD_3500        0xD0
#define         ARD_3750        0xE0
#define         ARD_4000        0xF0         


#define		RF_CH		0x05


#define		RF_SETUP	0x06
//bits
#define LNA_HCURR 0x01
#define RF_PWR    0x06
#define RF_PWR_18 0x00
#define RF_PWR_12 0x02
#define RF_PWR_6  0x04
#define RF_PWR_0  0x06
#define RF_DR     0x08
#define PLL_LOCK  0x10


#define		STATUS		0x07
//bits
#define TX_FULL   0x01
#define RX_P_NO   0x0E
#define RX_P_NO_0 0x00
#define RX_P_NO_1 0x02
#define RX_P_NO_2 0x04
#define RX_P_NO_3 0x06
#define RX_P_NO_4 0x08
#define RX_P_NO_5 0x0A
#define MAX_RT    0x10
#define TX_DS     0x20
#define RX_DR     0x40


#define		OBSERVE_TX	0x08
//bits
#define ARC_CNT  0x0F
#define PLOS_CNT 0xF0


#define		CD		0x09
//bits
#define         CDbit           0x01


#define		RX_ADDR_P0	0x0A
#define		RX_ADDR_P1	0x0B
#define		RX_ADDR_P2	0x0C
#define		RX_ADDR_P3	0x0D
#define		RX_ADDR_P4	0x0E
#define		RX_ADDR_P5	0x0F
#define		TX_ADDR		0x10


#define		RX_PW_P0	0x11
#define		RX_PW_P1	0x12
#define		RX_PW_P2	0x13
#define		RX_PW_P3	0x14
#define		RX_PW_P4	0x15
#define		RX_PW_P5	0x16


#define		FIFO_STATUS	0x17
//bits
#define RX_EMPTY  0x01
#define RX_FULL   0x02
#define TX_EMPTY  0x10
#define TX_FULL2  0x20
#define TX_REUSE  0x40


#define DYNPD 0x1C
//bits
#define DPL_P0  0x01
#define DPL_P1  0x02
#define DPL_P2  0x04
#define DPL_P3  0x08
#define DPL_P4  0x10
#define DPL_P5  0x20


#define		FEATURE         0x1D
//bits
#define EN_DYN_ACK 0x01
#define EN_ACK_PAY 0x02
#define EN_DPL     0x04



#define   IRQ             P2IN&BIT4


#define   LED1_ON         P3OUT &= ~BIT7;
#define   LED1_OFF        P3OUT |= BIT7;
#define   LED1_TOGGLE     P3OUT ^= BIT7;


